package adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import bean.AllTimeTableBean;
import bean.CourseraInfoBean;
import bean.ScheduleTableBean;
import student.andlei.com.student.R;
import utils.DateUtils;


public class AllTimeTableAdapter extends BaseQuickAdapter<ScheduleTableBean.Rooms,BaseViewHolder> {
    //格式化时间
    private SimpleDateFormat CurrentTime= new SimpleDateFormat("HH:mm");
    public AllTimeTableAdapter(int layoutResId, @Nullable List data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ScheduleTableBean.Rooms item) {
        helper.addOnClickListener(R.id.bt_look).addOnClickListener(R.id.bt_state);
        helper.setText(R.id.tv_subject,item.room_name);
        helper.setText(R.id.tv_name,item.teacher_name+"老师");
        helper.setText(R.id.tv_time,item.start_time+"--"+item.end_time);
        //0:表示无备课包，没有复习和预习按钮
//        if(item.bag_id==0){
//            helper.getView(R.id.bt_state).setVisibility(View.GONE);
//        }else {
//            helper.getView(R.id.bt_state).setVisibility(View.VISIBLE);
//        }
        //1:预习 2:复习
        if(item.status == 1){
            helper.setText(R.id.bt_state,"预习");
        }else {
            helper.setText(R.id.bt_state,"复习");
        }
        Button button =  helper.getView(R.id.bt_look);
        //1:暂未开始 2:进入课堂 3.查看录播 4：录播暂未上传
        switch (item.classroom_status){
            case 1:
                button.setBackgroundResource(R.drawable.bt_yellow_click);
                button.setText("进入课堂");
                break;
            case 2:
                button.setBackgroundResource(R.drawable.bt_yellow_click);
                button.setText("进入课堂");
                break;
            case 3:
                button.setBackgroundResource(R.drawable.bt_click);
                button.setText("查看录播");
                break;
            case 4:
                button.setBackgroundResource(R.drawable.bt_click);
                button.setText("查看录播");
                break;
        }
        //1:需要购买 0:不需要购买
//        if(item.is_buy==0){
//            try {
//                Date beginTime  =   CurrentTime.parse(item.start_time);
//                Date now =  CurrentTime.parse(DateUtils.getCurrentDatefour());
//                Date endTime = CurrentTime.parse(item.end_time);
//                if(now.getTime()<beginTime.getTime()){
//                    helper.setText(R.id.bt_look,"暂未开始");
//                    helper.getView(R.id.bt_look).setBackgroundResource(R.drawable.shape_gray);
//                }else if(beginTime.getTime()<now.getTime() && now.getTime()<endTime.getTime()){
//                    helper.setText(R.id.bt_look,"进入课堂");
//                    helper.getView(R.id.bt_look).setBackgroundResource(R.drawable.bt_yellow_click);
//                }
//                //if(now.getTime()>endTime.getTime())
//                else {
//                    helper.setText(R.id.bt_look,"查看录播");
//                    helper.getView(R.id.bt_look).setBackgroundResource(R.drawable.bt_click);
//                }
//            } catch (ParseException e) {
//                e.printStackTrace();
//            }
//        }else {
//
//        }
    }


}
